<#include "common/tags.ftl"/>
<!DOCTYPE html>
<html>

<head>
    <title>DianPu</title>
		<#include "common/meta.ftl"/>
    <link rel="stylesheet" type="text/css" href="${ctx}/static/uc/common/css/login.css"/>
</head>

<body>
<div class="m-login-bg">
    <div class="m-login">
        <h3>DianPu</h3>
        <div class="m-login-warp">
            <form class="layui-form">
                <div class="layui-form-item">
                    <input type="text" id="loginAccount" name="loginAccount" lay-verify="loginAccount"
                           placeholder="登录账号" autocomplete="off" class="layui-input" value="139">
                </div>
                <div class="layui-form-item">
                    <input type="password" id="password" name="password" lay-verify="password" placeholder="密码"
                           autocomplete="off" class="layui-input" value="Aa123456">
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <input type="text" name="verity" lay-verify="verity" placeholder="验证码" autocomplete="off"
                               class="layui-input" value="1234">
                    </div>
                    <div class="layui-inline">
                        <img class="verifyImg" onclick="this.src=this.src+'?c='+Math.random();" src=""/>
                    </div>
                </div>
                <div class="layui-form-item m-login-btn">
                    <div class="layui-inline">
                        <button class="layui-btn layui-btn-normal login" lay-submit="" lay-filter="login">登录</button>
                    </div>
                    <div class="layui-inline">
                        <button type="reset" class="layui-btn layui-btn-primary">取消</button>
                    </div>
                </div>
            </form>
        </div>
        <p class="copyright">Copyright 2015-2018 by DianPu</p>
    </div>
</div>
		<#include "common/script.ftl"/>
<script>
    layui.use(['jquery', 'ligutil', 'form'], function () {
        var $ = layui.jquery
                , form = layui.form
                , ligutil = layui.ligutil;

        //自定义验证规则
        form.verify({
            loginAccount: function (value) {
                if (value == '') {
                    return '登录账号不能为空';
                }
            }
            , password: function (value) {
                if (value == '') {
                    return '密码不能为空';
                }
            }
            , verity: function (value) {
                if (value == '') {
                    return '验证码不能为空';
                }
            }
        });
        /*
        //监听提交*/
        form.on('submit(login)', function (data) {
            ligutil.ajaxpost({
                url: ctx + 'authenticate'
                , data: data.field
                , success: function (result) {
                    if (result.success) {
                        window.location.href = ctx + 'index';
                    }
                }
            });
            return false;
        });
    });
</script>
</body>

</html>